#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QPainter>
#include <QDebug>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::paintEvent(QPaintEvent *event){
    QPainter painter;
    painter.begin(this);
    QBrush brush(Qt::green);
    painter.setBrush(brush);
    painter.drawRect(0, 0, 50, 100);

    brush.setColor(Qt::red);
    painter.setBrush(brush);

    painter.save();
    painter.translate(100, 50);
    painter.drawRect(0, 0, 50, 50);
    painter.restore();


    painter.save();
    painter.translate(200, 50);
    painter.rotate(-30);
    painter.drawRect(0, 0, 50, 100);
    painter.restore();

    painter.save();
    painter.translate(300, 50);
    painter.scale(0.5, 2);
    painter.drawRect(0, 0, 50, 100);
    painter.restore();

    painter.end();
}
